package com.cha.chaCommon.core.config;


import com.cha.chaCommon.core.intercepter.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
@Author  hkf
@date 2024/10/28
--轻舟已过万重山--
*/
@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // addPathPatterns 定义拦截的路径
        // excludePathPatterns 定义放行的路径
        String[] excludePatterns = new String[]{
                "/swagger-resources/**",
                "/webjars/**",
                "/v3/**",
                "/swagger-ui.html",
                "/swagger-ui/**",
                "/api-docs/**",
                "/doc.html",
               };
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**").excludePathPatterns(excludePatterns);

    }
}
